<?php
namespace app\souther\controller;

use app\common\model\Treasure as TreasureModel;
use think\Db;

class Treasure extends Base
{
	
	function __construct()
	{
		parent::_initialize();
	}

    /**
     * [index 列表]
     * @return [type] [description]
     * @author [南風]
     */
    public function index()
    {
        $model = new TreasureModel();

        if(request()->isPost()){
            try{
                $param = input('post.');
                if($param['id']==''){
                    $id = $model->addData($param);
                }else{
                    $id = $model->editData($param);
                }
            }catch(\Exception $e){
                writelog($e->getMessage(),-1);
                return admin_json(-1,$model->getError());
            }
            writelog('短信宝配置--'.$id);
            return admin_json(1,'成功','',url('/plug'));
        }
        
        $result = $model->find();

        return $this->fetch('',['edit'=>$result]);
    }

}